<!--
 * @Author: your name
 * @Date: 2022-01-10 14:28:31
 * @LastEditTime: 2022-01-10 16:02:56
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \elementui\src\components\Mydialog.vue
-->
<template>
  <div>
    <el-dialog :title="title" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="日期" :label-width="formLabelWidth">
          <el-input v-model="form.date" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="姓名" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="地址" :label-width="formLabelWidth">
          <el-input v-model="form.address" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="quxiao">取 消</el-button>
        <el-button type="primary" @click="addfn">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import instance from "../api";
export default {
  name: "Mydialog",
  props: ["title", "dialogFormVisible", "formLabelWidth", "tables"],
  data() {
    return {
      tableData: [],
      form: {
        name: "",
        date: "",
        address: "",
      },
      df:this.dialogFormVisible
    };
  },
  methods: {
    async addfn() {
      console.log(this.form);
      let name = this.form.name;
      let date = this.form.date;
      let address = this.form.address;
      if (!name || !date || !address) {
        return this.$message("内容不能为空");
      }
      console.log(name, date, address);
      await instance.post(this.tables, { name, date, address });
      this.df = false;
      this.$emit("df");
    },
    quxiao(){
        this.df = false;
        this.$emit("quxiao");
    }
  },
};
</script>

<style scope>
</style>